package com.markerhub.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.markerhub.entity.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.markerhub.vo.AddressOrderVo;
import com.markerhub.vo.OrderUserVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 */
public interface OrderMapper extends BaseMapper<Order> {

    @Select("select m_order.id orderid,m_order.user_id , m_user.username,m_user.avatar,m_order.ticklist_id ,\n" +
            "m_order.created tickcreatetime ,m_order.`status`  tickstatus,m_order.price ,m_order.id ,m_user.`status` , m_user.created FROM m_user \n" +
            " LEFT JOIN m_order ON m_user.id=m_order.user_id ")
    List<OrderUserVO> getOrderUser(Page<OrderUserVO> page);

//    @Select("select m_order.user_id,m_order.tick_id,m_order.id,m_order.created,m_order.price,m_tick.title,m_tick.description,m_tick.contet " +
//            " FROM m_order LEFT JOIN m_tick ON m_order.tick_id=m_tick.id " +
//            "where m_order.user_id=#{userid}")
    @Select("select m_order.*,m_tick.title,m_tick.description,m_tick.contet,m_tick.picture " +
            " FROM m_order LEFT JOIN m_tick ON m_order.tick_id=m_tick.id " +
            "where m_order.user_id=#{userid}")
    List<AddressOrderVo> getAddressOrder(Page<AddressOrderVo> page, @Param("userid") Integer userid);



    @Select("select m_order.*,m_tick.title,m_tick.description,m_tick.contet,m_tick.picture \n" +
            "             FROM m_order LEFT JOIN m_tick ON m_order.tick_id=m_tick.id  WHERE  m_order.use_time IS NULL AND  m_order.status=5 OR m_order.status=3")
    List<AddressOrderVo> getAllOrd(Page<AddressOrderVo> page);


}
